home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / winsock / ircii2-6.zip / SCRIPTS\HISTORY- < prev    next >
Text File  |  1994-12-28  |  2KB  |  49 lines

  1. # history-match
  2. # This is basically an attempt to emulate the behavior of tcsh's ESC-p
  3. # eg.. /partcom^Xp  looks for the completion to the command in the
  4. #        command history
  5. # and  /command partword^Xp  finds the match to the partial word in the
  6. #      command history.. Try it twice as it may miss it the first time
  7. # The other feature is that if there are several matches in the history
  8. # you can hit ^Xp several times to move through the choices.. if you 
  9. # modify the pattern or hit return it will reset the search to something
  10. # new.. 
  11.  
  12. @ RCS.ircIId = [$$Header: /splode/u/mrg/src/ircii-2.5/script/RCS/history-match,v 1.1 1994/07/30 18:15:56 mrg Stab $$]
  13.  
  14. bind meta2-p parse history.expn $L
  15.  
  16. # clearing out a null pattern is tough.. so I do it any time a line is
  17. # sent
  18. on #-input 765 * @ history.pat = [xxnomatchxx]
  19.  
  20. alias history.expn {
  21.     if ([$0] != history.key)
  22.     {
  23.         # again, trying to get rid of a 'short' or null pattern
  24.         @ history.pat = [xxnomatchxx]
  25.         @ history.key = [$0]
  26.     }
  27.     if (history.nomatch == []) {@ history.nomatch = 1}
  28.     if (!match($(history.pat)* $1)) {@ history.pat = [$1]}
  29.     @ history.found = 0
  30.     while (!history.found)
  31.     {
  32.         if ((history.search = [$(!$(0)!)]) != []) 
  33.         {
  34.             if (match($(history.pat)* $word(1 $history.search)))
  35.             {
  36.                 parsekey erase_to_beg_of_line
  37.                 xtype -literal $history.search
  38.                 @ history.found = 1
  39.                 @ history.nomatch = 0
  40.             }
  41.         }
  42.         {
  43.             # we hit the top of the history.. drop out of the while loop
  44.             @ history.found = 1
  45.             @ history.nomatch = 1
  46.         }
  47.     }
  48. }
  49.